#include "http_client.h"
#include <iostream>
#include <nlohmann/json.hpp> // 添加JSON库头文件
#include <fstream>
int main()
{
    HttpClient cli("main.dsgym.xin", 443);
    cli.setDefaultHeaders({{"User-Agent", "MyHttpsClient/1.0"},
                           {"Accept", "application/json"}});
    cli.enable_server_certificate_verification(false);
    cli.setTimeout(5);
    cli.setFollowRedirect(false);

    std::string path = "/cabinet/wx/qrcode?brand_code=Anke2101&env_version=trial";

    auto res = cli.get(path);
if (res.ok)
{
    std::cout << "请求状态码: " << res.status << std::endl;
    // 保存为图片文件
    std::ofstream fout("qrcode.jpg", std::ios::binary);
    fout.write(res.body.data(), res.body.size());
    fout.close();
    std::cout << "二维码已保存为 qrcode.jpg" << std::endl;
}
else
{
    std::cout << "请求错误: " << res.error << std::endl;
}

    return 0;
}